<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<div id="app">
			<cpn></cpn>
			<cpn ref="aaa"></cpn>
			<cpn></cpn>
			<button type="button" class="mui-btn mui-btn-blue" @click="btnClick">按钮</button>
		</div>
		<template id="cpn">
			<div>
				我是子组件
			</div>
		</template>
		<script src="../js/vue.js"></script>
		<script>
			const app=new Vue({
				el:'#app',
				data:{
					message:'你好'
				},
				methods:{
					btnClick(){
						//1.$children
						/* console.log(this.$children);
						for (let s of this.$children) {
							console.log(s.name);
							s.showMessage();
						} */
						//2.$refs ==>对象类型，默认是一个空的对象 ref="bbb"
						console.log(this.$refs.aaa.name);
					}
				},
				components:{
					cpn:{
						template:"#cpn",
						data(){
							return{
								name:"我是子组件mame"
							}
						},
						methods:{
							showMessage(){
								console.log('showMessage');
							}
						}
					}
				}
			})
		</script>
	</body>
</html>
